package com.xmb.wechat.bean;

import com.chad.library.adapter.base.entity.MultiItemEntity;

import java.util.Calendar;
import java.util.Date;

import io.objectbox.annotation.Entity;
import io.objectbox.annotation.Id;

/**
 * @Author lijiangop
 * @CreateTime 2020/4/22 17:48
 */
@Entity
public class AliPayBillBean implements MultiItemEntity, Comparable<AliPayBillBean> {
    @Id
    private long id;
    //common
    int    type = 0;//类型
    long   tradeTime;//时间
    String billClassify;//账单分类
    String money;//金额
    String iconUrl;//图标
    int    iconSourceType;//图标源图类型

    boolean isShowTradeState;
    String  tradeStateValue;//具体交易状态
    int     tradeState;//交易状态  0进行中  1已完成 2 已取消

    //网购
    String platformType;

    //转账
    boolean isExpend = true;//默认支出

    String title;//网购,提现,转账,花呗还款,自定义

    //月份item
    String monthInYear;
    String expend;
    String income;

    public AliPayBillBean() {
    }

    public AliPayBillBean(int type) {
        this.type = type;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public long getTradeTime() {
        return tradeTime;
    }

    public void setTradeTime(long tradeTime) {
        this.tradeTime = tradeTime;
    }

    public String getBillClassify() {
        return billClassify;
    }

    public void setBillClassify(String billClassify) {
        this.billClassify = billClassify;
    }

    public boolean isShowTradeState() {
        return isShowTradeState;
    }

    public void setShowTradeState(boolean showTradeState) {
        isShowTradeState = showTradeState;
    }

    public String getTradeStateValue() {
        return tradeStateValue;
    }

    public void setTradeStateValue(String tradeStateValue) {
        this.tradeStateValue = tradeStateValue;
    }

    public int getTradeState() {
        return tradeState;
    }

    public void setTradeState(int tradeState) {
        this.tradeState = tradeState;
    }

    public String getMoney() {
        return money;
    }

    public void setMoney(String money) {
        this.money = money;
    }

    public String getIconUrl() {
        return iconUrl;
    }

    public void setIconUrl(String iconUrl) {
        this.iconUrl = iconUrl;
    }

    public int getIconSourceType() {
        return iconSourceType;
    }

    public void setIconSourceType(int iconSourceType) {
        this.iconSourceType = iconSourceType;
    }

    public String getPlatformType() {
        return platformType;
    }

    public void setPlatformType(String platformType) {
        this.platformType = platformType;
    }

    public boolean isExpend() {
        return isExpend;
    }

    public void setExpend(boolean expend) {
        isExpend = expend;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getMonthInYear() {
        return monthInYear;
    }

    public void setMonthInYear(String monthInYear) {
        this.monthInYear = monthInYear;
    }

    public String getExpend() {
        return expend;
    }

    public void setExpend(String expend) {
        this.expend = expend;
    }

    public String getIncome() {
        return income;
    }

    public void setIncome(String income) {
        this.income = income;
    }

    @Override
    public String toString() {
        return "AliPayBillBean{" +
                "id=" + id +
                ", type=" + type +
                ", tradeTime=" + tradeTime +
                ", billClassify='" + billClassify + '\'' +
                ", money='" + money + '\'' +
                ", iconUrl='" + iconUrl + '\'' +
                ", iconSourceType=" + iconSourceType +
                ", isShowTradeState=" + isShowTradeState +
                ", tradeStateValue='" + tradeStateValue + '\'' +
                ", tradeState=" + tradeState +
                ", platformType='" + platformType + '\'' +
                ", isExpend=" + isExpend +
                ", title='" + title + '\'' +
                ", monthInYear='" + monthInYear + '\'' +
                ", expend='" + expend + '\'' +
                ", income='" + income + '\'' +
                '}';
    }

    @Override
    public int getItemType() {
        return type;
    }

    @Override
    public int compareTo(AliPayBillBean argEntity) {
        Calendar thisCalendar = Calendar.getInstance();
        thisCalendar.setTime(new Date(this.getTradeTime()));

        Calendar argCanlendar = Calendar.getInstance();
        argCanlendar.setTime(new Date(argEntity.getTradeTime()));

        if (thisCalendar.get(Calendar.YEAR) > argCanlendar.get(Calendar.YEAR)) {
            return -1;
        } else if (thisCalendar.get(Calendar.YEAR) == argCanlendar.get(Calendar.YEAR)) {//同年
            if (thisCalendar.get(Calendar.MONTH) > argCanlendar.get(Calendar.MONTH)) {
                return -1;
            } else if (thisCalendar.get(Calendar.MONTH) == argCanlendar.get(Calendar.MONTH)) {//同月
                if (thisCalendar.get(Calendar.DAY_OF_MONTH) > argCanlendar.get(Calendar.DAY_OF_MONTH)) {
                    return -1;
                } else if (thisCalendar.get(Calendar.DAY_OF_MONTH) == argCanlendar.get(Calendar.DAY_OF_MONTH)) {//同日
                    long l = thisCalendar.getTimeInMillis() - argCanlendar.getTimeInMillis();
                    return l > 0 ? -1 : 1;
                } else {
                    return 1;
                }
            } else {
                return 1;
            }
        } else {
            return 1;
        }
    }
}
